<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model app\models\Job */

$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => '职位列表', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>

<style type="text/css">
    table .btn {
        margin: 0.2em 0.8em;
        width: 180px;
    }
    button.power{width:350px;}
</style>

<div class="job-view" style="width: 800px;margin:0 auto;">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('修改', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('删除', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>
    </p>

    <table class="table table-striped table-bordered detail-view">
        <tbody>
            <tr>
                <th>ID</th>
                <td><?= $model->id ?></td>
            </tr>
            <tr>
                <th>职位名</th>
                <td><?= $model->name ?></td>
            </tr>
            <tr>
                <th>菜单操作权限</th>
                <td>
                    <table style="width:100%;border-top:1px #ccc solid;border-left:1px #ccc solid;">
                        <?php
                        if (null != $menu_array && count($menu_array) > 0) {
                            foreach ($menu_array as $root) {
                        ?>
                                <tr style="background-color: #fff;border-bottom:1px #ccc solid;">
                                    <td style="border-right: #ccc 1px solid;" width="200">
                                        <button class="btn btn-default" value="<?= $root['id'] ?>"><?= $root['name'] ?></button>
                                    </td>
                                    <td style="border-right: #ccc 1px solid;" width="600" id="menu_root_<?= $root['id'] ?>_children">
                                        <?php if (null != $root['children']) {
                                            foreach ($root['children'] as $menu) { ?>
                                                <button class="btn btn-default" value="<?= $menu['id'] ?>"><?= $menu['name'] ?></button>
                                        <?php }
                                        } ?>
                                    </td>
                                </tr>

                        <?php
                            }
                        }
                        ?>
                    </table>
                </td>
            </tr>
            <tr>
                <th>患者操作权限</th>
                <td>
                    <?php
                    if (null != $patient_power_array && count($patient_power_array) > 0) {
                        foreach ($patient_power_array as $d) {
                            echo '<button class="btn btn-default power" value="' . $d['id'] . '">' . $d['instruction'].'：'.$d['var_name'].'：'.$d['operate'] . '</button>';
                        }
                    }
                    ?>
                </td>
            </tr>
        </tbody>
    </table>

</div>